package com.zjny.constant;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 日期相关常量
 * </p>
 *
 * @author cui haida
 */
public class DateConstant {

    /**
     * 一天时间(毫秒)
     */
    public static final long ONE_DAY_TIME = 24 * 60 * 60 * 1000L;

    /**
     * 概数词语
     */
    public static final List<String> ROUND_NUMBER_FLAG = Arrays.asList("附近", "估计", "约", "概", "几", "来", "左右", "上下", "把", "多", "近", "余", "一二", "二三", "两三", "三五", "三四", "四五", "五六", "六七", "七八", "八九");

    /**
     * 日期
     */
    public static final String UNIT_YEAR = "年";
    public static final String YEAR_OF_TWENTY = "20";
    public static final String AREA_UNIT_REGEX = "0|o|O|〇|○";
    public static final String UNIT_MONTH = "月";
    public static final String UNIT_GE_MONTH = "个月";
    public static final String UNIT_DAY = "日";
    public static final String UNIT_HOUR = "小时";
    public static final String UNIT_GE_HOUR = "个小时";
    public static final String UNIT_ONLY_HOUR = "时";
    public static final String UNIT_MINUTE = "分";
    public static final String UNIT_MINUTE_ZHONG = "分钟";
    public static final String UNIT_SECOND = "秒";
    public static final String UNIT_ZHONG = "钟";
    public static final String UNIT_WEEK = "周";
    public static final String UNIT_TIAN = "天";
    public static final String UNIT_HAO = "号";
    public static final String UNIT_GE = "个";

    // 各种常用的日期格式
    public static final String YYYY = "yyyy";
    public static final String YYYY_MM = "yyyy-MM";
    public static final String YYYY_MM_DD = "yyyy-MM-dd";
    public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
    public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
    public static final String[] PARSE_PATTERNS = {
            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
            "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
            "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};

    /**
     * 获取dataFormat
     * 用ThreadLocal防止并发问题
     */
    public static final ThreadLocal<DateFormat> df = ThreadLocal.withInitial(() -> new SimpleDateFormat(YYYY_MM_DD));

    // period
    public static final String PERIOD_REGEX = "止|为止|起";
    public static final String ZHI = "至";
    public static final String ARRIVE = "到";

    // 天数
    public static final Integer YEAR_DAYS = 365; // 年天数
    public static final Integer MONTH_DAYS = 30; // 月天数

    /**
     * 年相关的map -> 200x年处理
     */
    public static final Map<String, String> MAP_OF_YEAR = new HashMap<String, String>() {{
        put("两千", "2000");
        put("千禧", "2000");
        put("两千零一", "2001");
        put("两千零二", "2002");
        put("两千零三", "2003");
        put("两千零四", "2004");
        put("两千零五", "2005");
        put("两千零六", "2006");
        put("两千零七", "2007");
        put("两千零八", "2008");
        put("两千零九", "2009");
    }};
}
